package com.supermarket.api.web.admin;

import com.supermarket.api.bean.user.TokenData;
import com.supermarket.api.common.BaseResponse;
import com.supermarket.api.entity.UserInfoEntity;
import com.supermarket.api.service.UserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 登录用户相关接口
 * @author 李其伟
 * @date 2023/10/29
 */
@Api(tags = "登录用户相关接口")
@Slf4j
@RestController
@RequestMapping("/admin/user")
public class AdminUserInfoController {

    @Autowired
    private UserInfoService userService;

    @ApiOperation(value = "退出系统", notes = " ")
    @PostMapping ("/logout")
    public String logout(@RequestBody TokenData tokenData) {
        return BaseResponse.successJson(userService.logout(tokenData));
    }

    @ApiOperation(value = "查询用户信息", notes = " ")
    @GetMapping("/info")
    public String info() {
        return BaseResponse.successJson(userService.info());
    }

    @ApiOperation(value = "修改用户信息", notes = " ")
    @PostMapping ("/update")
    public String update(@RequestBody UserInfoEntity userInfo) {
        return BaseResponse.successJson(userService.update(userInfo));
    }

}
